#include<bits/stdc++.h>
using namespace std;

//rp++
int n,a[200005];
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int T;
    cin>>T;
    while(T--)
    {
        cin>>n;
        int sum=0;

        for(int i=1;i<=n;i++)
        {
            int x;
            cin>>x;
            a[x]++;
            if(a[x]%2==0)sum+=x;
        }
        cout<<sum<<endl;
    }
    

    return 0;
}